import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument } from 'mongoose';

export type TodoDocument = HydratedDocument<Todo>;

@Schema({ timestamps: true }) // timestamps: true 会自动添加 createdAt 和 updatedAt 字段
export class Todo {
  @Prop({ required: true })
  task: string;
  @Prop({ required: true })
  state: 'todo' | 'pending' | 'done';
  @Prop({ required: true })
  startTime: string;
  @Prop({ required: true })
  endTime: string;
}

// 从 Todo 类创建 Mongoose Schema
export const TodoSchema = SchemaFactory.createForClass(Todo);
